package com.ftwj.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftwj.entity.SchoolRoomSeatInfo;
import com.ftwj.mapper.SchoolRoomSeatMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.UUID;

@Service
public class SchoolRoomSeatService {

    @Autowired
    private SchoolRoomSeatMapper schoolRoomSeatMapper;



    public int insertSchoolRoomSeatInfo(SchoolRoomSeatInfo schoolRoomSeatInfo){
        if (schoolRoomSeatInfo.getId() == null || schoolRoomSeatInfo.getId().isEmpty()){
            String newId = UUID.randomUUID().toString();  // 生成UUID
            schoolRoomSeatInfo.setId(newId);
            System.out.println("Generated UUID: " + newId);  // 输出生成的UUID
        }else {
            System.out.println("Using provided ID: " + schoolRoomSeatInfo.getId());  // 输出提供的ID
        }
        return schoolRoomSeatMapper.insertSchoolRoomSeatInfo(schoolRoomSeatInfo);
    }

    public int updateSchoolRoomSeatInfo(SchoolRoomSeatInfo schoolRoomSeatInfo){
        return schoolRoomSeatMapper.updateSchoolRoomSeatInfo(schoolRoomSeatInfo);
    }

    public int updateSchoolRoomSeatOpenState(SchoolRoomSeatInfo schoolRoomSeatInfo){
        return schoolRoomSeatMapper.updateSchoolRoomSeatOpenState(schoolRoomSeatInfo);
    }

    public int deleteSchoolRoomSeatInfo(String id){
        return schoolRoomSeatMapper.deleteSchoolRoomSeatInfo(id);
    }

    public IPage<Map<String, Object>> selectSchoolRoomSeatInfoAll(Page<Map<String, Object>> page) {
        // 使用正确的 Page 类型进行分页查询
        IPage<Map<String, Object>> schoolRoomSeatList = schoolRoomSeatMapper.selectSchoolRoomSeatInfoAll(page);
        return schoolRoomSeatList;
    }

}
